
package com.example.rabbitmq.config;

import com.codahale.metrics.Counter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Metric Config class
 * 度量起配置类
 */
@Slf4j
@Configuration
public class MetricConfig {
    @Bean
    public MetricRegistry metric() {
        return new MetricRegistry();
    }

//    @Bean
//    public ConsoleReporter consoleReporter(MetricRegistry metrics) {
//        return ConsoleReporter.forRegistry(metrics).
//    }

    @Bean
    public Counter pendingJobs(MetricRegistry metrics) {
        return metrics.counter("requestCount");
    }
    /**
     * 计时器
     *
     * @param metrics
     * @return
     */
    @Bean
    public Timer responses(MetricRegistry metrics) {
        return metrics.timer("executeTime");
    }



}
